<?php
class testStd extends stdClass
{
    function set_var($v)
    {
        foreach($v as $key => $value) {
            if(is_array($value)) {
                foreach($value as $k => $vs) {
                    $this->$key->$k = $vs;
                }
            } else {
                $this->$key = $value;
            }
        }
    }

    function set_link($n, $v)
    {
        if(is_array($v)) {
            foreach($v as $key => $value) {
                $this->$n->$key = $value;
            }
        } else {
            $this->$n = $v;
        }
    }

}

$test = array(
    array(
        'id' => 1,
        'name' => 'allen',
    ),
    array(
        'id' => 2,
        'name' => 'luoyi',
    ),
    array(
        'id' => 3,
        'name' => 'roy',
    ),
    array(
        'id' => 4,
        'name' => 'alixroo',
    ),
    array(
        'id' => 5,
        'name' => 'allen.luo',
    ),
);
$t = new testStd();
$t->set_var($test);


dump($t);

function dump($v) {
    echo '<pre>';
    print_r($v);
    echo '</pre>';
}